package com.yupi.springbootinit.config;

import org.apache.catalina.session.StandardSessionFacade;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator{

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response){
        HttpSession httpSession=(HttpSession) request.getHttpSession();
        sec.getUserProperties().put(HttpSession.class.getName(),httpSession);
        StandardSessionFacade ssf=(StandardSessionFacade) request.getHttpSession();
        if(ssf!=null){
            HttpSession httpSession1=(HttpSession) request.getHttpSession();
            sec.getUserProperties().put("sessionId",response);
        }
    }
}
